package day5;

import java.io.FileInputStream;
import java.io.FileOutputStream;

public class TestFileInputStream {
  public static void main(String[] args) {
	//读磁盘下的文件 参数是文件的路径
	  FileInputStream in = null;
	  FileOutputStream out = null;
	  try {
	 in = 
			  new FileInputStream("C:\\Users\\12093\\Pictures\\Saved Pictures\\70ee9bb15f89705b5e7cdb153358b1da.jpg");
     //构建一个输出流 写在某个目录下  文件可以不存在
	  out = new FileOutputStream("F:\\学习\\king.jpg");
    //in.read();   //循环一直全部读完图片位置 in.read == -1
    int len = -1;
    byte[] arr = new byte[2048];
    while((len = in.read(arr))!= -1) {//终止条件 in.read()= -1
    	 //把文件写道磁盘下的其他地方  此时数组里是图片字节
    	out.write(arr,0,len);  
    	out.flush();
    }} catch (Exception e) {
	  e.printStackTrace();
	  
  }finally {
	  try {      // 关流
		  in.close();
		  out.close();
	  } catch (Exception e) {
		  e.printStackTrace();
	  }
  }
  
}
  
}